package com.itwill.ecom.company;

import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository("companyDao")
public class CompanyDaoImpl implements CompanyDao {
	public final static String namespace="com.itwill.ecom.company.CompanyMapper";
	@Autowired
	private SqlSession session;

	public SqlSession getSession() {
		return session;
	}

	public void setSession(SqlSession session) {
		System.out.println("#### CompanyDao() : setSession()");
		this.session = session;
	}
	
	public CompanyDaoImpl() {
		System.out.println("#### CompanyDao() : 디폴트생성자 호출  ");
	}
	
	@Override
	public int create(CompanyBeans company){
		return session.insert(namespace + ".create", company);
	}

	@Override
	public List<CompanyBeans> searchAllList(){
		return session.selectList(namespace + ".readAll");
	}
	
	@Override
	public CompanyBeans readByNo(int companyno){
		return session.selectOne(namespace + ".readByNo", companyno);
	}
	
	@Override
	public int update(CompanyBeans company){
		return session.update(namespace + ".update", company);
	}

	@Override
	public int delete(int companyno){
		return session.delete(namespace + ".delete", companyno); 
	}
}